package cd.safe.school.util;

import java.io.File;

import android.media.MediaRecorder;
import android.os.Environment;

public class Record {
	private MediaRecorder mr;

	public void start(String path) {
		mr = new MediaRecorder();
		mr.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
		mr.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
		mr.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
		File file = new File(path);
		if (!file.getParentFile().exists())
			file.getParentFile().mkdirs();
		mr.setOutputFile(file.getAbsolutePath());
		try {
			mr.prepare();
			// 开始录音
			mr.start();
		} catch (Exception e) {

			e.printStackTrace();
		}

	}

	public void stop() {
		mr.stop();
		mr.release();
		mr = null;

	}

}
